<?php
	namespace Common\Logic;
	use Common\Model\GoodsListModel;
	class GoodsListLogic extends GoodsListModel{
		/*
		* Function:		getGoodsListList
		* Description:	商品规格明细列表
		* @param:		$page string 起始页
						$filter array 过滤数组
						$pageSize string 每页显示条数
		*/
		public function getGoodsListList($page=1,$filter = '',$pageSize=20){
			$conditon = $this->getGoodsListFilter($filter);
			return $this->where($conditon)->order('id desc')->limit(($page-1)*$pageSize,$pageSize)->select();
		}
		
		/*
		* Function:get:	getGoodsListFilter
		* Description:	商品规格明细列表搜索过滤项
		* @param:		$filter array 过滤数组
		*/
		public function getGoodsListFilter($filter = ''){
			$conditon = array();
			if(!empty($filter['goods_title'])){
				$conditon['goods_title'] = array('like','%'.$filter['goods_title'].'%');
			}
			return $conditon;
		}
		
		/*
		* Function:get:	getGoodsListCount
		* Description:	商品规格明细列表总数
		* @param:		$filter array 过滤数组
		*/
		public function getGoodsListCount($filter = ''){
			$conditon = $this->getGoodsListFilter($filter);
			return $this->where($conditon)->count();
		}
		
		/*
		* Function:		addGoodsList
		* Description:	增加商品规格明细
		* @param:		$data array 增加的数组
		*/
		public function addGoodsList($data){
			return $this->add($data);
		}
		
		/*
		* Function:		getGoodsListInfo
		* Description:	获取商品规格明细信息 by row
		* @param:		$id int ID
		*/
		public function getGoodsListInfo($id){
			return $this->where(array('id'=>$id))->find();
		}
		
		/*
		* Function:		updateGoodsList
		* Description:	更新商品规格明细
		* @param:		$data array 更新的数组
		*/
		public function updateGoodsList($data){
			return $this->save($data);
		}
		
		/*
		* Function:		deleteGoodsList
		* Description:	删除商品规格明细
		* @param:		$id int ID
		*/
		public function deleteGoodsList($id){
			return $this->where(array('id'=>$id))->delete();
		}

		/*
		* Function:		getGoodsListAllList
		* Description:	商品规格列表
		*/
		public function getGoodsListAllList($goods_id = ''){
			$conditon = [];
			$conditon['status'] = 1;
			if(!empty($goods_id)){
				$conditon['goods_id'] = $goods_id;
			}
			return $this->where($conditon)->select();
		}
	}
?>